package com.eshore.norm.pattern.singleton.demo1;

import java.lang.reflect.Constructor;

/**
 * TODO
 *
 * @author: v-chenjl62
 * @date: 2024/1/30 15:56
 */
public class Client {

    public static void main(String[] args) throws Exception {
//        Singleton instance = Singleton.getInstance();
//        Singleton instance2 = Singleton.getInstance();
//        System.out.println(instance==instance2);

        //反射破坏测试
        Class clazz = Singleton.class;
        Constructor constructor = clazz.getDeclaredConstructor();
        constructor.setAccessible(true);

        Singleton s1 = (Singleton) constructor.newInstance();
        Singleton s2 = (Singleton) constructor.newInstance();
        System.out.println(s1==s2);
    }

}
